home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Applications / mint / arch.txt < prev    next >
Text File  |  1994-05-19  |  4KB  |  79 lines

  1. MacMiNT Architecture Summary
  2.  
  3. MacMiNT is composed of 2 main programs: JET and MiNT.  JET (Just
  4. Enough TOS) is a Mac application that installs interrupt, exception,
  5. and trap handlers to make the Mac look like an Atari running TOS.  JET
  6. loads MiNT which adds multi-tasking and other UNIX like features to
  7. TOS (or JET in this case).  This document describes some of the
  8. handlers that JET uses to pretend the Mac is an Atari.
  9.  
  10. The most essential emulation of TOS is in trap handling.  JET installs
  11. handlers for traps 1, 13, and 14 to handle DOS, BIOS, and XBIOS calls
  12. (note 1).  These traps are called by TOS programs by putting a short
  13. value on the stack indicating what OS function is requested, followed
  14. by the parameters for that function.  The trap dispatchers use this
  15. value to index into an array of functions to handle each request.  JET
  16. only has handlers for functions used by MiNT.  Most other functions
  17. are handled by MiNT. When a program running under MiNT make a trap
  18. call, it often involves trapping in to MiNT, JET, and the Mac Toolbox.
  19. All of this trap overhead is the main reason for the slowness of
  20. MacMiNT relative to what you would expect on an Atari.  The speed of
  21. the Macs relative to the Atari's helps to balance the problem out.
  22. See Atari/Programming/gemdos.arc for more info on TOS functions.
  23.  
  24. MiNT multitasking is provided for by installing a context switching
  25. function in the VBL (vertical blanking) interrupt handler (mint:
  26. main.c, intr.s, context.s, timeout.c).  JET sets up a VBL routine and
  27. a level 1 interrupt handler to dispatch to the MiNT VBL handler (jet:
  28. vector.c, intr.c).  The VBL routine sets a flag that the interrupt
  29. handler watches for.  Normally the interrupt handler just returns to
  30. the code that was interrupted, but if the flag has been set (every
  31. 1/60th second), then the MiNT VBL is invoked.  JET also installs
  32. TimeManager routines that go off every 20ms and 5ms to support the
  33. other interrupts that MiNT expects.  The 20ms timer is used to
  34. maintain a system time keeping value.  All other interrupts are
  35. handled by the MacOS and are converted into the standard MacOS events
  36. like mouseDown, keyDown, etc.
  37.  
  38. There is one MiNT process that gets built into the MiNT kernel (mint:
  39. main.c) whose only job is to repeatedly call a function that allows
  40. JET to process MacOS events.  MacOS events are processed with
  41. WaitNextEvent to allow other applications to get CPU time.
  42.  
  43. JET doesn't really install exception handlers.  It does save the
  44. original exceptions handlers, though, because MiNT installs some of
  45. its own exception handlers.  The main ones are bus error, address
  46. error, illegal instruction, divide by zero, and trace.  These
  47. exceptions are turned into signals that are sent to the MiNT process
  48. that caused them.  The handling of these exceptions by MiNT make it
  49. possible to support debuggers like GDB.
  50.  
  51. JET installs its vectors before it passes control to MiNT and
  52. de-installs them when control is passed back from MiNT.  Because the
  53. vectors are not installed while JET is in control, it is possible to
  54. debug JET using standard debugging tools like THINK C's debugger and
  55. Macsbug.  It is possible for JET to loose control of the CPU when it
  56. calls WaitNextEvent.  If JET didn't remove its vectors, then other
  57. programs that messed around with these vectors might not work.  It is
  58. possbile to run two copies of JET because it was designed to be
  59. multi-finder friendly.
  60.  
  61. The functions for installing and removeing the vectors are included in
  62. the sysvar data structure so that they can be called from MiNT and by
  63. programs running under MiNT.  They are called put_vector and
  64. pull_vector.  If you are going to call Mac Toolbox routines, it is
  65. safest if you enter supervisor mode to prevent process pre-emption and
  66. call pull_vector to allow Macsbug to work and avoid any problems if
  67. MacMiNT looses the CPU.
  68.  
  69. Brad Pickering brad@tazboy.jpl.nasa.gov
  70.  
  71. PS - Please let me know if you know how to make this clearer or more
  72. complete.
  73.  
  74. notes:
  75.  
  76. 1.  Macsbug uses traps 13 and/or 14 to support stepping through
  77. instructions.  This functionality of Macsbug can not be used when JET
  78. has its handlers installed.
  79.